home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Utilities / InstallerMaker™ / InstallerMaker__2.0.2_Installe / InstallerMaker™ 2.0.2 Installer / InstallerMaker Extensions / ICnd Extension / HasFPUICnd.c next >
Text File  |  1994-03-23  |  4KB  |  118 lines

  1. /* ****************************************************************
  2.  
  3.         HasFPUICnd.c
  4.                     Written in Symantec Think C 6.0 by Robert Thorne (rmt).
  5.                     Translated from the MPW Pascal original 
  6.                     written by Darryl Lovato (dgl)
  7.                     and Jim Merritt (jam).
  8.                     
  9.         Copyright © 1994 Aladdin Systems, Inc.
  10.         All Rights Reserved.
  11.         
  12.         This source text produces an ICnd
  13.         installer extension, which can be called by a Product
  14.         Installer during the installation process.  Specifications
  15.         for IBeg, IMid, ICnd, and IEnd extensions are given in the
  16.         documentation for StuffIt InstallerMaker™ 2.0.  Note that this
  17.         code should be built into a code resource of type 'ICnd' with
  18.         a resource ID of 128
  19.         
  20.         This subroutine checks whether the Mac running a product installer
  21.         has an FPU unit installed.  Custom Condition Bit 0 requests a check
  22.         for the FPU being present; Custom Condition Bit 1 requests a check for
  23.         the FPU's absense.  It works as follows:
  24.         
  25.         
  26.         (1) if Custom Condition Bit 0 is set:
  27.         
  28.         • Returns 0 (i.e., install the associated item) if the FPU is present.
  29.         • Returns 1 (i.e., do NOT install the associated item) if
  30.           the FPU is NOT present.
  31.         
  32.         (2) if Custom Condition Bit 1 is set:  
  33.         • Returns 0 (i.e., install the associated item) if the FPU is not present.
  34.         • Returns 1 (i.e., do NOT install the associated item) if
  35.           the FPU is present.
  36.           
  37.         (3) otherwise, return 0 (i.e., install the current item)
  38.                  
  39.         
  40.         CHANGE HISTORY:
  41.         
  42.         VER    DATE        ENGR    DESCRIPTION
  43.         1    93.06.21    dgl        Prototype version.
  44.         2    93.06.23    jam        Added commentary, modified style to
  45.                                 match other source files in the
  46.                                 InstallerMaker suite, increased
  47.                                 portability across various Pascal
  48.                                 compilers, and rearranged logic to
  49.                                 provide for "care/don't care"
  50.                                 interpretation of custom condition
  51.                                 bit 0 setting in the installermaker
  52.                                 archive window.
  53.         3    94.03.07    rmt        Translated into Think C
  54.         4    94.03.23    rmt        Converted to IM 2.0 calling conventions.
  55.         
  56. ****************************************************************** */
  57.  
  58. // Apple Include Files
  59. #include <Types.h>
  60. #include <GestaltEqu.h>
  61.  
  62. // Installer Constants
  63. #define kSkipThisItem 1
  64. #define kInstallThisItem 0
  65. #define kMaskForCustomBit0 0x0001
  66. #define kMaskForCustomBit1 0x0002
  67.  
  68. // Constants for our example
  69. #define kHasFPUCustomBit kMaskForCustomBit0
  70. #define kLacksFPUCustomBit kMaskForCustomBit1
  71.  
  72.  
  73. // The call to the code resource.  In Think C, we call the resource as "main",
  74. // with the following arguments.  Note that we return a "short", returning 
  75. // either kSkipThisItem if our condition is false, and kInstallThisItem if the
  76. // condition holds, and we can install.  The installer passes us a short integer
  77. // that may have some combination of the least significant three bits set.  These
  78. // correspond to the three custom condition settings of the main Installer Maker
  79. // screen.
  80.  
  81. pascal short main ( unsigned short flags, unsigned short packages )
  82. {
  83.     long    result ;
  84.     
  85.     // First, test if bit 0 is set; if it isn't, we have no objection to installing
  86.     // the current item.
  87.     
  88.     // We check to see if the installer is interested in whether an FPU is 
  89.     // installed; if any other bit is set, or no bit is set, bless the
  90.     // installation of the current item and go away.
  91.         
  92.     if ( flags & kHasFPUCustomBit  || flags & kLacksFPUCustomBit )
  93.     {
  94.         // An interesting bit is set; we now test if the FPU is present
  95.         if ( Gestalt(gestaltFPUType,&result) == noErr )
  96.         {
  97.             
  98.             if ( flags & kHasFPUCustomBit )
  99.                 return (result !=  gestaltNoFPU) ? 
  100.                     kInstallThisItem :  // We have FPU, so OK
  101.                     kSkipThisItem ;        // We don't
  102.             else
  103.                 return (result ==  gestaltNoFPU) ? 
  104.                     kInstallThisItem :  // We don't have an FPU, so OK
  105.                     kSkipThisItem ;        // We do
  106.                 
  107.         }
  108.         else
  109.             // Gestalt failed for some reason; we assume we don't have an FPU
  110.             return (flags & kLacksFPUCustomBit) ?
  111.                 kInstallThisItem :
  112.                  kSkipThisItem ;
  113.     }
  114.     else 
  115.         // This item doesn't check for FPU, so we give the go-ahead:
  116.         return kInstallThisItem ;
  117. }
  118.